package com.example.shardingdemo.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.shardingdemo.entity.CityDO;
import com.example.shardingdemo.entity.UserDO;
import com.example.shardingdemo.mapper.CityMapper;
import com.example.shardingdemo.mapper.SysUserMapper;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class IndexController {

    @Resource
    private CityMapper cityMapper;

    @Resource
    private SysUserMapper userMapper;

    @RequestMapping("/save")
    public String save(CityDO cityDO) {
        cityMapper.insert(cityDO);
        return "ok";
    }

    @RequestMapping("/list")
    public List<CityDO> list() {
        return cityMapper.selectList(new LambdaQueryWrapper<>());
    }

    @RequestMapping("/page")
    public Page<UserDO> page() {
        return userMapper.selectPage(new Page<>(1,200), new LambdaQueryWrapper<>());
    }


}
